Skip to content

Conversation

@gabrielhicks
Copy link
Contributor

Added intelligent fallback logic and dedicated commands to handle additional validator stake operations when transient accounts are in use, making stake management more user-friendly and automated.

  • Enhanced increase-validator-stake and decrease-validator-stake commands with --allow-additional flag
    • Provides clear error messages with actionable suggestions when fallback is not enabled
  • increase-additional-validator-stake Directly increase stake using ephemeral accounts with optional --ephemeral-seed flag
  • decrease-additional-validator-stake Directly decrease stake using ephemeral accounts with optional --ephemeral-seed flag
  • Added find_unused_ephemeral_stake_seed helper to find next-available ephemeral stake accounts via brute force iteration

Usage:

# Traditional usage (unchanged)
spl-stake-pool increase-validator-stake <pool> <validator> 13.37

# With automatic fallback 
spl-stake-pool increase-validator-stake <pool> <validator> 42.69 --allow-additional

# Direct additional stake operations
spl-stake-pool increase-additional-validator-stake <pool> <validator> 42.69

@gabrielhicks
Copy link
Contributor Author

gabrielhicks commented Aug 21, 2025

@joncinque tagging from discord

Copy link
Contributor

@joncinque joncinque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay on the review -- really great work! Mostly small things, then we can land this. The semver failure is unrelated

Comment on lines +203 to +207
// Account exists - check if it's initialized (has non-zero data)
if account.data.iter().all(|&x| x == 0) {
// Account exists but is uninitialized, can use this seed
return Ok(seed);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this check is sufficient -- the program tries to allocate and assign the ephemeral stake without checking its prior state, so this check should also include account.owner == system_program::id()

Comment on lines +1037 to +1048
let ephemeral_stake_seed = match ephemeral_stake_seed {
Some(seed) => seed,
None => {
// Find an unused ephemeral stake seed
find_unused_ephemeral_stake_seed(
&config.rpc_client,
&config.stake_pool_program_id,
stake_pool_address,
u64::MAX, // Check all possible ephemeral seeds
)?
}
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: probably better to do this after the update, in case any accounts get cleaned up in the process

Comment on lines +1080 to +1091
let ephemeral_stake_seed = match ephemeral_stake_seed {
Some(seed) => seed,
None => {
// Find an unused ephemeral stake seed
find_unused_ephemeral_stake_seed(
&config.rpc_client,
&config.stake_pool_program_id,
stake_pool_address,
u64::MAX, // Check all possible ephemeral seeds
)?
}
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: same here, probably better to do it after updating

.arg(
Arg::with_name("allow_additional")
.long("allow-additional")
.short("aa")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: let's avoid two-letter short flags and remove this entirely

.long("allow-additional")
.short("aa")
.takes_value(false)
.help("Allow automatic fallback to additional validator stake with ephemeral accounts if transient stake is in use"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit for clarity

Suggested change
.help("Allow automatic fallback to additional validator stake with ephemeral accounts if transient stake is in use"),
.help("Allow automatic fallback to increase-additional-validator-stake with ephemeral accounts if transient stake is in use"),

.arg(
Arg::with_name("allow_additional")
.long("allow-additional")
.short("aa")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: same here, no two-letter short flags, please

.long("allow-additional")
.short("aa")
.takes_value(false)
.help("Allow automatic fallback to additional validator stake with ephemeral accounts if transient stake is in use"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: same here for clarity

Suggested change
.help("Allow automatic fallback to additional validator stake with ephemeral accounts if transient stake is in use"),
.help("Allow automatic fallback to decrease-additional-validator-stake with ephemeral accounts if transient stake is in use"),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants